<script setup>
import { RouterView } from 'vue-router'
import Side from './components/Side.vue'
import Breadcrumb from './components/Breadcrumb.vue'
import { useRoute } from 'vue-router';
import { ref } from 'vue'

const route = useRoute();
const isCollapsed = ref(false)

const handleCollapse = (collapsed) => {
  isCollapsed.value = collapsed
}

// tooltip.value = {
//     show: true,
//     x: rect.left + (rect.width / 2), // 居中对齐
//     y: svgRect.top + 40, // 固定在染色体上方
//     gene
//   };
// };
</script>

<template>
  <div v-if="route.path === '/login' || route.path === '/register'">
    <RouterView />
  </div>
  <el-container v-else class="app-container">
    <el-aside>
      <Side class="side-nav" @collapse-change="handleCollapse" />
    </el-aside>
    <el-container>
      <el-header>
        <Breadcrumb class="breadcrumb" />
      </el-header>
      <el-main>
        <RouterView />
      </el-main>
    </el-container>
  </el-container>

  
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background-color: #f5f7fa;
}

.side-nav {
  height: 100vh;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.el-aside {
  position: relative;
  transition: all 0.3s ease;
}

.el-container {
  flex: 1;
  overflow: hidden;
}

.el-header {
  background: #fff;
  padding: 0;
  height: 50px !important;
  line-height: 50px;
  border-bottom: 1px solid #eee;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.el-main {
  padding: 0;
  overflow-y: auto;
  background-color: #f5f7fa;
  height: calc(100vh - 50px);
}

.breadcrumb {
  /* padding: 0 20px; */
  background: transparent;
  height: 100%;
  /* display: flex; */
  align-items: center;
}

:deep(.el-breadcrumb) {
  line-height: 50px;
}

:deep(.el-breadcrumb__item) {
  display: flex;
  align-items: center;
}

:deep(.el-breadcrumb__inner) {
  color: #606266;
  font-weight: normal;
}

:deep(.el-breadcrumb__inner.is-link:hover) {
  color: #409EFF;
}

@media screen and (max-width: 768px) {
  .el-aside {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .el-aside.is-open {
    transform: translateX(0);
  }

  .el-main {
    padding: 0;
  }
}
</style>
